package cn.com.pg.b2b.pd.truck.appointment.management.service.common;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * Description: ResponseDTO
 * @author: Wang, Jingzhu
 * @CreateDate: 2021-01-20
 */
@Setter
@Getter
public class ResponseDTO<T> implements Serializable {

    private static final long serialVersionUID = -2818895476780760649L;

    public static final ResponseDTO<?> ERROR = new ResponseDTO<>(ReturnCode.ERROR);

    private int code = ReturnCode.SUCCESS.getCode();

    private Date timestamp = new Date();

    private String message = ReturnCode.SUCCESS.getMessage();

    private transient T data;

    private String token;

    public ResponseDTO() {}

    public ResponseDTO(T data) {
        this.data = data;
    }

    public ResponseDTO(T data, Integer code) {
        this.data = data;
        this.code = code;
    }

    public ResponseDTO(T data, String token) {
        this.data = data;
        this.token = token;
    }

    public ResponseDTO(T data, String token, String message) {
        this.data = data;
        this.token = token;
        this.message = message;
    }

    public ResponseDTO(T data, ReturnCode returnCode) {
        this.data = data;
        this.code = returnCode.getCode();
        this.message = returnCode.getMessage();
    }

    public ResponseDTO(T data, ReturnCode returnCode, String token) {
        this(data, returnCode);
        this.token = token;
    }

    public ResponseDTO(ReturnCode returnCode) {
        this.code = returnCode.getCode();
        this.message = returnCode.getMessage();
    }

    public ResponseDTO(ReturnCode returnCode, String token) {
        this(returnCode);
        this.token = token;
    }

    public ResponseDTO(Integer code, String message) {
        this.code=code;
        this.message=message;
    }

    public ResponseDTO(T data, Integer code, String message) {
        this.data=data;
        this.code=code;
        this.message=message;
    }

    public void setReturnCode(ReturnCode returnCode) {
        this.code = returnCode.getCode();
        this.message = returnCode.getMessage();
    }

    
    
}
